---
title: OpenAI Moderation Guardrail
sidebarTitle: OpenAI Moderation
description: Learn about the OpenAI Moderation Guardrail and how to use it with your Agents.
---

The OpenAI Moderation Guardrail is a built-in guardrail that detects content that violates OpenAI's content policy in the input of your Agents.

This can be helpful to detect content that violates OpenAI's content policy faster and without firing the unsucessful API request.

It can also be useful if you are using a different provider but still want to use the OpenAI Moderation guidelines.

## Usage

To use the OpenAI Moderation Guardrail, you need to import it and pass it to the Agent with the `pre_hooks` parameter:

```python
from agno.guardrails import OpenAIModerationGuardrail
from agno.agent import Agent
from agno.models.openai import OpenAIChat

openai_moderation_guardrail = OpenAIModerationGuardrail()

agent = Agent(
    name="OpenAI Moderation Guardrail Agent",
    model=OpenAIChat(id="gpt-5-mini"),
    pre_hooks=[openai_moderation_guardrail],
)
```

## Moderation model

By default, the OpenAI Moderation Guardrail will use OpenAI's `omni-moderation-latest` model.

You can adjust which model is used for moderation by providing the `moderation_model` parameter:

```python
openai_moderation_guardrail = OpenAIModerationGuardrail(
    moderation_model="omni-moderation-latest",
)
```

## Moderation categories

You can specify which categories the guardrail should check for.

By default, the guardrail will consider all the existing moderation categories. You can check the list of categories in [OpenAI's docs](https://platform.openai.com/docs/guides/moderation#content-classifications).

You can override the default list of moderation categories using the `raise_for_categories` parameter:

```python
openai_moderation_guardrail = OpenAIModerationGuardrail(
    raise_for_categories=["violence", "hate"],
)
```



## Developer Resources

- View [Examples](/examples/concepts/agent/guardrails)
- View [Reference](/reference/hooks/openai-moderation-guardrail)
- View [Cookbook](https://github.com/agno-agi/agno/tree/main/cookbook/agents/guardrails)